# Maintainer: Alexandros Theodotou <alex@zrythm.org>

_realname=sratom
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=0.6.18
pkgrel=1
pkgdesc='A C library for serializing LV2 atoms to and from RDF (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: sratom'
)
msys2_repository_url='https://gitlab.com/lv2/sratom/'
url='https://drobilla.net/software/sratom.html'
license=('spdx:0BSD OR ISC')
depends=("${MINGW_PACKAGE_PREFIX}-lv2"
         "${MINGW_PACKAGE_PREFIX}-serd"
         "${MINGW_PACKAGE_PREFIX}-sord")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-pkgconf")
source=(https://download.drobilla.net/${_realname}-${pkgver}.tar.xz{,.sig})
sha256sums=('4c6a6d9e0b4d6c01cc06a8849910feceb92e666cb38779c614dd2404a9931e92'
            'SKIP')
validpgpkeys=('907D226E7E13FA337F014A083672782A9BF368F3') # David Robillard <d@drobilla.net>

build() {
  mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/meson setup \
      --prefix="${MINGW_PREFIX}" \
      --wrap-mode=nodownload \
      --auto-features=enabled \
      --buildtype=plain \
      -Ddocs=disabled \
      ../${_realname}-${pkgver}

  ${MINGW_PREFIX}/bin/meson compile
}

check() {
  cd "${srcdir}/build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/meson test || warning "Tests failed"
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/meson install
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
